package liheng.vue.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import liheng.vue.typehandler.StringArrayTypeHandler;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.JdbcType;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@ApiModel("员工对象")
@Data
@NoArgsConstructor
@AllArgsConstructor
//autoResultMap = true typeHandler处理结果集时使用
@TableName(value = "t_emp",autoResultMap = true)
public class Emp implements Serializable {
    public static final String HOBBIES_SPLIT = ",";

    @ApiModelProperty("编号")
    @TableId(value = "id",type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("姓名")
    private String name;

    @ApiModelProperty("工资")
    private Double salary;

    @ApiModelProperty("性别")
    private String sex;

    @ApiModelProperty("学历")
    private String edu;

    @ApiModelProperty("爱好")
    //数组转换成数据库中的varchar，中间逗号分割
    @TableField(typeHandler = StringArrayTypeHandler.class)
    private String[] hobbies;

    @ApiModelProperty("简介")
    private String description;

    @ApiModelProperty("入职日期")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField(jdbcType = JdbcType.DATE)
    private Date hireDate;

    @ApiModelProperty("状态")
    private String status;
}
